using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using VSSAHT.Transfer;
using VSS_AHT.DataAccess;

namespace VSSAHT.DataAccess
{
	public partial class ItemMapper
	{
		#region ToEntity

		public static Item ToEntity(Item entity, ItemDTO businessobject)
		{
			if (businessobject == null)
			{
				return null;
			}
			entity.ItemID = businessobject.ItemID;
			entity.ItemName = businessobject.ItemName;
			entity.ItemNumber = businessobject.ItemNumber;
			entity.ItemUnit = businessobject.ItemUnit;
            entity.ItemUnit2 = businessobject.ItemUnit2;
			entity.OnhandQuantity = businessobject.OnhandQuantity;
            entity.RowVersion = VersionConverter.ToBinary(businessobject.RowVersion);
			return entity;
		}

        		#endregion

        #region ToModel

        #endregion

        #region ToBusinessObject

        public static ItemDTO ToBusinessObject(Item entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ItemDTO
			{
				ItemID = entity.ItemID,
				ItemName = entity.ItemName,
				ItemNumber = entity.ItemNumber,
				ItemUnit = entity.ItemUnit,
                ItemUnit2=entity.ItemUnit2,
				OnhandQuantity = entity.OnhandQuantity,
                RowVersion = VersionConverter.ToString(entity.RowVersion)
			};
		}

		#endregion

		#region ToBusinessObjectHasChildren

		public static ItemDTO ToBusinessObjectHasChildren(Item entity, params Type[] types)
		{
			if (entity == null)
			{
				return null;
			}
			ItemDTO businessobject = new ItemDTO
			{
				ItemID = entity.ItemID,
				ItemName = entity.ItemName,
				ItemNumber = entity.ItemNumber,
				ItemUnit = entity.ItemUnit,
				OnhandQuantity = entity.OnhandQuantity,
                RowVersion = VersionConverter.ToString(entity.RowVersion)
			};
			return businessobject;
		}

		#endregion

	}
}
